﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="SearchContact.aspx.cs" Inherits="SearchContact" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:Label ID="Label1" runat="server" Text="Search By Name"></asp:Label><asp:TextBox ID="SearchText"  runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="SearchText" ErrorMessage="*" ForeColor="#0066FF" ValidationGroup="Go"></asp:RequiredFieldValidator>
    &nbsp;<asp:Button ID="Btn_Search" runat="server" OnClick="Btn_Search_Click" Text="Go" ValidationGroup="Go" />
&nbsp;<asp:Label ID="lab_membernames" runat="server" Visible="False"></asp:Label>
    <br />
    <asp:GridView ID="GridView2"  EmptyDataText="No records" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource2">
        <Columns>
           
            <asp:BoundField DataField="ID" Visible="false" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
            <asp:BoundField DataField="PhoneNo" HeaderText="PhoneNo" SortExpression="PhoneNo" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" />
            <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
            <asp:BoundField DataField="BirthDay" HeaderText="BirthDay" SortExpression="BirthDay" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
            <asp:ImageField   HeaderText="Image"  DataImageUrlField="ImagePath" SortExpression="ImagePath" />
             <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DBCS %>" DeleteCommand="DELETE FROM [Contact] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Contact] ([Name], [Age], [PhoneNo], [Email], [Location], [Gender], [BirthDay], [Address], [ImagePath]) VALUES (@Name, @Age, @PhoneNo, @Email, @Location, @Gender, @BirthDay, @Address, @ImagePath)" SelectCommand="SELECT [ID], [Name], [Age], [PhoneNo], [Email], [Location], [Gender], [BirthDay], [Address], [ImagePath] FROM [Contact] WHERE (([Name] = @Name) AND ([MemberName] = @MemberName))" UpdateCommand="UPDATE [Contact] SET [Name] = @Name, [Age] = @Age, [PhoneNo] = @PhoneNo, [Email] = @Email, [Location] = @Location, [Gender] = @Gender, [BirthDay] = @BirthDay, [Address] = @Address, [ImagePath] = @ImagePath WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Age" Type="Int32" />
            <asp:Parameter Name="PhoneNo" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="Location" Type="String" />
            <asp:Parameter Name="Gender" Type="String" />
            <asp:Parameter Name="BirthDay" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="ImagePath" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="SearchText" DefaultValue="none" Name="Name" PropertyName="Text" Type="String" />
            <asp:SessionParameter Name="MemberName" SessionField="name" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Age" Type="Int32" />
            <asp:Parameter Name="PhoneNo" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="Location" Type="String" />
            <asp:Parameter Name="Gender" Type="String" />
            <asp:Parameter Name="BirthDay" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="ImagePath" Type="String" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <br />
    <asp:Label ID="Lab_Notfond" runat="server"></asp:Label>
    <br />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="2" DataKeyNames="ID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" AllowPaging="True">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            
            <asp:BoundField DataField="ID" Visible="false" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Age" HeaderText="Age" SortExpression="Age" />
            <asp:BoundField DataField="PhoneNo" HeaderText="PhoneNo" SortExpression="PhoneNo" />
            <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
            <asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" />
            <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
            <asp:BoundField DataField="BirthDay" HeaderText="BirthDay" SortExpression="BirthDay" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
            <asp:BoundField DataField="ImageName" Visible="false" HeaderText="ImageName" SortExpression="ImageName" />
            <asp:ImageField   HeaderText="Image"  DataImageUrlField="ImagePath" SortExpression="ImagePath" />
            <asp:BoundField DataField="MemberName" Visible="false" HeaderText="MemberName" SortExpression="MemberName" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
    <br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:DBCS %>" DeleteCommand="DELETE FROM [Contact] WHERE [ID] = @original_ID AND (([Name] = @original_Name) OR ([Name] IS NULL AND @original_Name IS NULL)) AND (([Age] = @original_Age) OR ([Age] IS NULL AND @original_Age IS NULL)) AND (([PhoneNo] = @original_PhoneNo) OR ([PhoneNo] IS NULL AND @original_PhoneNo IS NULL)) AND (([Email] = @original_Email) OR ([Email] IS NULL AND @original_Email IS NULL)) AND (([Location] = @original_Location) OR ([Location] IS NULL AND @original_Location IS NULL)) AND (([Gender] = @original_Gender) OR ([Gender] IS NULL AND @original_Gender IS NULL)) AND (([BirthDay] = @original_BirthDay) OR ([BirthDay] IS NULL AND @original_BirthDay IS NULL)) AND (([Address] = @original_Address) OR ([Address] IS NULL AND @original_Address IS NULL)) AND (([ImageName] = @original_ImageName) OR ([ImageName] IS NULL AND @original_ImageName IS NULL)) AND (([ImagePath] = @original_ImagePath) OR ([ImagePath] IS NULL AND @original_ImagePath IS NULL)) AND (([MemberName] = @original_MemberName) OR ([MemberName] IS NULL AND @original_MemberName IS NULL))" InsertCommand="INSERT INTO [Contact] ([Name], [Age], [PhoneNo], [Email], [Location], [Gender], [BirthDay], [Address], [ImageName], [ImagePath], [MemberName]) VALUES (@Name, @Age, @PhoneNo, @Email, @Location, @Gender, @BirthDay, @Address, @ImageName, @ImagePath, @MemberName)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [ID], [Name], [Age], [PhoneNo], [Email], [Location], [Gender], [BirthDay], [Address], [ImageName], [ImagePath], [MemberName] FROM [Contact] WHERE ([MemberName] = @MemberName)" UpdateCommand="UPDATE [Contact] SET [Name] = @Name, [Age] = @Age, [PhoneNo] = @PhoneNo, [Email] = @Email, [Location] = @Location, [Gender] = @Gender, [BirthDay] = @BirthDay, [Address] = @Address, [ImageName] = @ImageName, [ImagePath] = @ImagePath, [MemberName] = @MemberName WHERE [ID] = @original_ID AND (([Name] = @original_Name) OR ([Name] IS NULL AND @original_Name IS NULL)) AND (([Age] = @original_Age) OR ([Age] IS NULL AND @original_Age IS NULL)) AND (([PhoneNo] = @original_PhoneNo) OR ([PhoneNo] IS NULL AND @original_PhoneNo IS NULL)) AND (([Email] = @original_Email) OR ([Email] IS NULL AND @original_Email IS NULL)) AND (([Location] = @original_Location) OR ([Location] IS NULL AND @original_Location IS NULL)) AND (([Gender] = @original_Gender) OR ([Gender] IS NULL AND @original_Gender IS NULL)) AND (([BirthDay] = @original_BirthDay) OR ([BirthDay] IS NULL AND @original_BirthDay IS NULL)) AND (([Address] = @original_Address) OR ([Address] IS NULL AND @original_Address IS NULL)) AND (([ImageName] = @original_ImageName) OR ([ImageName] IS NULL AND @original_ImageName IS NULL)) AND (([ImagePath] = @original_ImagePath) OR ([ImagePath] IS NULL AND @original_ImagePath IS NULL)) AND (([MemberName] = @original_MemberName) OR ([MemberName] IS NULL AND @original_MemberName IS NULL))">
        <DeleteParameters>
            <asp:Parameter Name="original_ID" Type="Int32" />
            <asp:Parameter Name="original_Name" Type="String" />
            <asp:Parameter Name="original_Age" Type="Int32" />
            <asp:Parameter Name="original_PhoneNo" Type="String" />
            <asp:Parameter Name="original_Email" Type="String" />
            <asp:Parameter Name="original_Location" Type="String" />
            <asp:Parameter Name="original_Gender" Type="String" />
            <asp:Parameter Name="original_BirthDay" Type="String" />
            <asp:Parameter Name="original_Address" Type="String" />
            <asp:Parameter Name="original_ImageName" Type="String" />
            <asp:Parameter Name="original_ImagePath" Type="String" />
            <asp:Parameter Name="original_MemberName" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Age" Type="Int32" />
            <asp:Parameter Name="PhoneNo" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="Location" Type="String" />
            <asp:Parameter Name="Gender" Type="String" />
            <asp:Parameter Name="BirthDay" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="ImageName" Type="String" />
            <asp:Parameter Name="ImagePath" Type="String" />
            <asp:Parameter Name="MemberName" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="lab_membernames" Name="MemberName" PropertyName="Text" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Name" Type="String" />
            <asp:Parameter Name="Age" Type="Int32" />
            <asp:Parameter Name="PhoneNo" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="Location" Type="String" />
            <asp:Parameter Name="Gender" Type="String" />
            <asp:Parameter Name="BirthDay" Type="String" />
            <asp:Parameter Name="Address" Type="String" />
            <asp:Parameter Name="ImageName" Type="String" />
            <asp:Parameter Name="ImagePath" Type="String" />
            <asp:Parameter Name="MemberName" Type="String" />
            <asp:Parameter Name="original_ID" Type="Int32" />
            <asp:Parameter Name="original_Name" Type="String" />
            <asp:Parameter Name="original_Age" Type="Int32" />
            <asp:Parameter Name="original_PhoneNo" Type="String" />
            <asp:Parameter Name="original_Email" Type="String" />
            <asp:Parameter Name="original_Location" Type="String" />
            <asp:Parameter Name="original_Gender" Type="String" />
            <asp:Parameter Name="original_BirthDay" Type="String" />
            <asp:Parameter Name="original_Address" Type="String" />
            <asp:Parameter Name="original_ImageName" Type="String" />
            <asp:Parameter Name="original_ImagePath" Type="String" />
            <asp:Parameter Name="original_MemberName" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>

</asp:Content>

